﻿#ifndef MAINTENANCEANDCORRECTION_H
#define MAINTENANCEANDCORRECTION_H

#include <QObject>
#include <CommonHelper.h>
#include <Connect/UdpClient.h>
#include <DbHelper.h>
#include <QSerialPortInfo>
#include <QFileDialog>
#include <algorithm>
#include <QtMath>
#include <QJsonArray>
#include <QJsonObject>
#include <QTextCodec>
#include <QMetaEnum>
#include <Connect/CpsUdpClient.h>

class MaintenanceAndCorrection: public QObject
{
    Q_OBJECT

signals:
    void dellog();

public:
    MaintenanceAndCorrection();
    ~MaintenanceAndCorrection();

    Q_INVOKABLE void restoreInitialState();
    Q_INVOKABLE void stop();
    Q_INVOKABLE void reset(QString,QString,QString);
    Q_INVOKABLE int getSyringNum(QString);
    Q_INVOKABLE void singleStop(QString);

    //夹爪
    Q_INVOKABLE void runningClampingJaw(QString);
    Q_INVOKABLE void readMotorPosition(QString,QString);
    Q_INVOKABLE void writeMotorPosition(QString,QString,QString);

    Q_INVOKABLE void readSwitchCover(QString);
    Q_INVOKABLE void writeSwitchCover(QString,QString,QString);


    Q_INVOKABLE void runningPeristalticPump(QString,QString,QString,QString);


    Q_INVOKABLE void runningBarrier(QString);
    Q_INVOKABLE void readAirpump(QString);
    Q_INVOKABLE void writeAirpump(QString,QString);

    Q_INVOKABLE void runningRisingCongestion(QString);
    Q_INVOKABLE void runningZMove(QString);
    Q_INVOKABLE void runningSucker(QString);
    Q_INVOKABLE void readSucker(QString);
    Q_INVOKABLE void writeSucker(QString,QString);

    Q_INVOKABLE void runningXDirection(QString);
    Q_INVOKABLE void runningMovingTarget(QString);
    Q_INVOKABLE void runningFeed(QString);
    Q_INVOKABLE void readHeliumGasPump(QString);
    Q_INVOKABLE void writeHeliumGasPump(QString,QString);

    //注射器
    Q_INVOKABLE QVariantList getSyringInfo();
    Q_INVOKABLE QVariantList getSyringDetails(QString);
    Q_INVOKABLE bool delSyring(QString);
    Q_INVOKABLE bool alldelhc();
    Q_INVOKABLE bool saveSyring(QString,QString,QString,QVariantList);
    Q_INVOKABLE QStringList canInsertConsumablesType();

    Q_INVOKABLE void runningSyring(QString,QString,QString,QString);
    Q_INVOKABLE QStringList calculateSteps(QString,QString,QString,QString,QString,QString);
    Q_INVOKABLE QString getSerial();
    Q_INVOKABLE QString checkSyringParameter(QString,QString,QString,QString,QString,QString,QString,QString);
    Q_INVOKABLE int exportSyringConfig(QString);
    Q_INVOKABLE int importSyringConfig();

    Q_INVOKABLE void runningValve(QString,QString);

    //转盘
    Q_INVOKABLE void readPos(QString);
    Q_INVOKABLE void turnTurnTable(QString,QString);
    Q_INVOKABLE void saveData(int);
    Q_INVOKABLE void setInitialPosition(QString,QString);

    //气泵
    Q_INVOKABLE void setAirPumpPressure(QString,QString);
    Q_INVOKABLE void readAirPumpPressure();


    //通信日志
    Q_INVOKABLE QVariantList getLog();
    Q_INVOKABLE void delLog();
    Q_INVOKABLE void exportLog();

    //故障信息维护
    Q_INVOKABLE QJsonArray getFaultInformation();
    Q_INVOKABLE void updateFaultInformation(QString,QString,QString,QString);
    Q_INVOKABLE bool addFaultInformation();
    Q_INVOKABLE void blockFaultInformation(QString,QString,QString);


    //检测信息维护
    Q_INVOKABLE QJsonArray getDetectorInformation();
    Q_INVOKABLE void updateDetectorInformation(QString,QString,QString );


    Q_INVOKABLE QVariantList getComponentInfoList(QString);
    Q_INVOKABLE int getComponentUseStatus(QString,QString);
    Q_INVOKABLE void saveComponentInfo(QString,QVariantList);

    //维护所有动作 -cnr
    Q_INVOKABLE void maintenanceAction(QString action);
    Q_INVOKABLE void getAir(QString type);
    Q_INVOKABLE void setAir(QString type, QString value);
    Q_INVOKABLE void getHqAir(QString type);
    Q_INVOKABLE void setHqAir(QString type, QString value);
    Q_INVOKABLE void getXqbAir(QString type);
    Q_INVOKABLE void setXqbAir(QString type, QString value);
    Q_INVOKABLE void dry(QString time,QString kg);
    Q_INVOKABLE void getXpAir();
    Q_INVOKABLE void setXpAir(QString type1,QString type2);
    Q_INVOKABLE void getZbZZ(QString type);
    Q_INVOKABLE void setZbZZ(QString type,QString sd, QString value);
    Q_INVOKABLE void getZbXZ(QString type);
    Q_INVOKABLE void setZbXZ(QString type,QString value2,QString value);
    Q_INVOKABLE void runZbZZ(QString type,QString sd, QString value);
    Q_INVOKABLE void runZbXZ(QString type,QString value2, QString value);
    Q_INVOKABLE void getZbKG(QString type);
    Q_INVOKABLE void setZbKG(QString type,QString sd, QString value);
    Q_INVOKABLE void runZbKG(QString type,QString sd, QString value);
    Q_INVOKABLE void getZbHX(QString type);
    Q_INVOKABLE void setZbHX(QString type,QString sd, QString value);
    Q_INVOKABLE void runZbHX(QString type,QString sd, QString value);
    Q_INVOKABLE void getZbXPDJ(QString type);
    Q_INVOKABLE void setZbXPDJ(QString type,QString sd, QString value);
    Q_INVOKABLE void runZbXPDJ(QString type,QString sd, QString value);
    Q_INVOKABLE void getZbRD(QString type);
    Q_INVOKABLE void setZbRD(QString type, QString value, QString value2);
    Q_INVOKABLE void runZbRD(QString type, QString value,QString value2);
    Q_INVOKABLE void runQFB(QString type, QString type2,QString type3);
    Q_INVOKABLE void runCHFW(QString type);
    Q_INVOKABLE void getCHDJC(QString type1);
    Q_INVOKABLE void setCHDJC(QString type1, QString type2, QString type3, QString type4);
    Q_INVOKABLE void getCHMAXXC(QString type1);
    Q_INVOKABLE void setCHMAXXC(QString type1, QString type2);
    Q_INVOKABLE void runCHYXCS(QString type1, QString type2, QString type3, QString type4);
    Q_INVOKABLE void runCHStopCS(QString type1);
    Q_INVOKABLE void getZBxpyl();
    Q_INVOKABLE void getDBhqyl();
    Q_INVOKABLE void getStateInfo();
    Q_INVOKABLE void getStateInfos(QString type);

    Q_INVOKABLE void operationCpsReadData(int type);
    Q_INVOKABLE void zbrundcf(QString type);
    Q_INVOKABLE void dbrundcf(QString type);
    Q_INVOKABLE void runjgjr(QString type);
    Q_INVOKABLE void zbjr(QString time, QString value);
    Q_INVOKABLE void qlcgq(QString type, QString value);
    Q_INVOKABLE void getlsjll(QString type, QString type3);
    Q_INVOKABLE void setlsjll(QString type, QString type2, QString type3);
    Q_INVOKABLE void runCHFM(QString type);
    Q_INVOKABLE void getQBYL();
    Q_INVOKABLE void setQBYL(QString value1, QString value2);
    Q_INVOKABLE void CHJR(QString type1, QString type2);
    Q_INVOKABLE void setCHDJBH(QString type1, QString type2);
    Q_INVOKABLE void setCHFWFS(QString type1, QString type2);
    Q_INVOKABLE void CHLG(QString type1);
    Q_INVOKABLE void HJWZ(QString type);
    Q_INVOKABLE void ZBQG(QString type);
    Q_INVOKABLE void ZSD(QString type);
    Q_INVOKABLE void getDBLSJ(QString type1, QString type2);
    Q_INVOKABLE void setDBLSJ(QString type1, QString type2, QString value);
    Q_INVOKABLE void getcgqsl();
    Q_INVOKABLE void setcgqsl(QString value);
    Q_INVOKABLE void runrdb(QString djbh, QString fx, QString sd, QString sj);
    Q_INVOKABLE void rundjyx(QString hc, QString djbh);
private:
    UdpClient *udpClient;
    CpsUdpClient *cpsUdpClient;
    QTimer *timSend=new QTimer;// 定时器

};
#endif // MAINTENANCEANDCORRECTION_H
